package edu.upf.da.p2p.objects;

import java.io.Serializable;
import java.net.MalformedURLException;
import java.net.URL;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class UserContent implements Serializable {

	private static final long serialVersionUID = 369642485138257655L;
	private URL url;
	private String user;
	private static final Log log = LogFactory.getLog(UserContent.class);

	/**
	 * Para construir un {@link UserContent} a partir de la ID de la base
	 * de datos local.
	 * @param idDB
	 * @throws MalformedURLException
	 */
	public UserContent(int idDB,String user){
		try{
			this.user = user;
			url = new URL("p2p",user,"/"+idDB);
		} catch (MalformedURLException e1) {
			if(log.isErrorEnabled()){
				log.error("Error al construir la URL para la imagen con ID: ",e1);
			}
		}
	}
	public URL getURL() {
		return url;
	}

	public String getUser() {
		return user;
	}

	public void setURL(URL anURL) {
		url = anURL;
	}

	public void setUser(String aUser) {
		user = aUser;
	}

}
